#include "Scorer.h"

class Scorer2012 : public Scorer {
    public:
        virtual double score(Node* node) {
            double area = width * height;
            double pbb_area = node->get_area(alpha, beta);
            double AR = min(area, pbb_area) / max(area, pbb_area);
            vector<Node*> leafs;
            node->get_leafs(&leafs);
            double e_sum = node->sum_relative_areas();
            double score = 0.0;
//            if(node->get_width(alpha, beta) > width || node->get_height(alpha, beta) > height)
//                return 0.0;
            for(int i = 0; i < leafs.size(); i++) {
                double ideal_area = (leafs.at(i)->get_image()->get_relative_area() / e_sum) * pbb_area;
                double individual_score = min(ideal_area, leafs.at(i)->get_image()->get_area()) / max(ideal_area, leafs.at(i)->get_image()->get_area());
                if(individual_score > 0.5)
                    score += individual_score;
            }
            return (score / (double)leafs.size()) * AR;
        }
};
